package com.shangcheng.goods.handler;

/**
 * @PackageName: com.shangcheng.goods.handler
 * @ClassName: BaseExceptionHandler
 * @Author: zhouyangyang
 * @Date: 2020/7/26 2:08
 * @Description:
 */

import com.zhouyangyang.entity.Result;
import com.zhouyangyang.entity.StatusCode;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * 统一异常处理类
 */
@ControllerAdvice //声明该类是个增强类
@Slf4j
public class BaseExceptionHandler {
    @ExceptionHandler(value = Exception.class)
    @ResponseBody
    public Result error(Exception e){
        log.error("error {}",e.getMessage());
        return new Result(false, StatusCode.ERROR,"当前系统繁忙,请您稍后重试");
    }
}
